﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Crude.Common
{    
    [DataContract]
    public class ProjectDependency :  IEquatable<ProjectDependency>
    {
        [DataMember(Order=0)]
        public string Name { get; set; }

        [DataMember(Order = 1)]
        public string Version { get; set; }


        public override int GetHashCode()
        {
            return Name.GetHashCode() * 27 + Version.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as ProjectDependency);
        }

        public bool Equals(ProjectDependency other)
        {
            if (other == null)
            {
                return false;
            }
            else if (!string.Equals(Name, other.Name))
            {
                return false;
            }
            else if (!string.Equals(Version, other.Version))
            {
                return false;
            }

            return true;
        }
    }
}
